package com.han.nettytestdemo.connector;

import android.util.Log;


/**
 * Created by guoping on 16/8/1.
 */
public class LogUtil {

    public static void v(String tag, String data) {
//        if (BuildConfig.LOG_ENABLED) {
            if (tag == null || tag.length() == 0
                    || data == null || data.length() == 0)
                return;

            int segmentSize = 3 * 1024;
            long length = data.length();
            if (length <= segmentSize ) {// 长度小于等于限制直接打印
                Log.v(tag, data);
            }else {
                while (data.length() > segmentSize ) {// 循环分段打印日志
                    String logContent = data.substring(0, segmentSize );
                    data = data.replace(logContent, "");
                    Log.v(tag, logContent);
                }
                Log.v(tag, data);// 打印剩余日志
            }
//        }
    }

    public static void d(String tag, String data) {
//        if (BuildConfig.LOG_ENABLED) {
            if (tag == null || tag.length() == 0
                    || data == null || data.length() == 0)
                return;

            int segmentSize = 3 * 1024;
            long length = data.length();
            if (length <= segmentSize ) {// 长度小于等于限制直接打印
                Log.d(tag, data);
            }else {
                while (data.length() > segmentSize ) {// 循环分段打印日志
                    String logContent = data.substring(0, segmentSize );
                    data = data.replace(logContent, "");
                    Log.d(tag, logContent);
                }
                Log.d(tag, data);// 打印剩余日志
            }
//        }
    }

    public static void e(String tag, String data) {
//        if (BuildConfig.LOG_ENABLED) {
            if (tag == null || tag.length() == 0
                    || data == null || data.length() == 0)
                return;

            int segmentSize = 3 * 1024;
            long length = data.length();
            if (length <= segmentSize ) {// 长度小于等于限制直接打印
                Log.e(tag, data);
            }else {
                while (data.length() > segmentSize ) {// 循环分段打印日志
                    String logContent = data.substring(0, segmentSize );
                    data = data.replace(logContent, "");
                    Log.e(tag, logContent);
                }
                Log.e(tag, data);// 打印剩余日志
            }
//        }
    }
}
